package com.itheima.d8_tcp5.ZengTest;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintStream;
import java.net.Socket;

/**
 * @ClassName serverThread
 * @Author 16799
 * @Date 2025/9/27 11:12
 * @Version 1.0
 * @Description TODO
 **/
public class serverThread extends Thread{
    private Socket socket;
    public serverThread(Socket socket) {
        this.socket = socket;
    }

    @Override
    public void run() {
        try {
            OutputStream os = socket.getOutputStream();
            PrintStream ps = new PrintStream(os);
            ps.println("HTTP/1.1 200 OK");
            ps.println("Content-Type:text/html;charset=UTF-8");
            ps.println(); // 必须换行
            //换行之后，才可以开始真正的响应一个网页内容给浏览器
            ps.println("<div style='color:red;font-size:120px;text-align:center'>黑马程序员666<div>");
            ps.close();
            socket.close();
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}
